<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>MTB CAT1 Peripheral driver library: Calibration procedure</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.cypress.com/"><img alt="Logo" src="IFXCYP_one-line.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">MTB CAT1 Peripheral driver library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__group__sar2__calibration.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Calibration procedure<div class="ingroups"><a class="el" href="group__group__sar2.html">SAR2         (Analog to Digital Converter (ADC))</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<p><br />
</p>
<p>To start the procedure, perform <a class="el" href="group__group__sar2.html#group_sar2_config">Configuration Example</a> and <a class="el" href="group__group__sar2.html#group_sar2_init">Initialization</a> with included extra channel, which can be re-used after this procedure is complete: </p><div class="fragment"><div class="line"><span class="comment">/* Scenario: Third channel was selected to be used in the calibration </span></div><div class="line"><span class="comment">    * procedure. */</span></div><div class="line"></div><div class="line"><a class="code" href="structcy__stc__sar2__channel__config__t.html">cy_stc_sar2_channel_config_t</a> pass_0_saradc_0_sar_0_channel_2_config = </div><div class="line">{</div><div class="line">    .<a class="code" href="structcy__stc__sar2__channel__config__t.html#af729622f4adf0f92a2a1f53301d3297b">channelHwEnable</a> = <span class="keyword">true</span>,</div><div class="line">    .triggerSelection = <a class="code" href="group__group__sar2__enums.html#ggaba3cfba41b39cb3b447d613b48229198ab102cc947b2422987beff93cd93b6e1a">CY_SAR2_TRIGGER_OFF</a>,</div><div class="line">    .channelPriority = 0U,</div><div class="line">    .preenptionType = <a class="code" href="group__group__sar2__enums.html#ggab8244721c05442758f3f1b61792e80c6adad4692d5e03374a5d77f72abe90ddc9">CY_SAR2_PREEMPTION_ABORT_RESUME</a>,</div><div class="line">    .isGroupEnd = <span class="keyword">true</span>,</div><div class="line">    .pinAddress = 0U,</div><div class="line">    .portAddress = 0U,</div><div class="line">    .extMuxEnable = <span class="keyword">false</span>,</div><div class="line">    .extMuxSelect = 0U,</div><div class="line">    .preconditionMode = <a class="code" href="group__group__sar2__enums.html#gga75f6f289e993b67ada3222e4394c378ba4336c541eae52db68665714ea09d1999">CY_SAR2_PRECONDITION_MODE_OFF</a>,</div><div class="line">    .overlapDiagMode = <a class="code" href="group__group__sar2__enums.html#gga481e014914f83c1d91387b4adb96fa07ad80b5136f3dfbf9340edb28dbd1ad2d3">CY_SAR2_OVERLAP_DIAG_MODE_OFF</a>,</div><div class="line">    .sampleTime = 120U,</div><div class="line">    .postProcessingMode = <a class="code" href="group__group__sar2__enums.html#ggaeb91f0e98ffd0ccf1fbc9ac4ee4d2ecfa3b0a64bbb1dd1aeeaaaaf3157c1c8eaa">CY_SAR2_POST_PROCESSING_MODE_NONE</a>,</div><div class="line">    .resultAlignment = <a class="code" href="group__group__sar2__enums.html#gga063234382f49c6003504631cdcc2c098a83feb25c8aedebb31abc5da43b6617ff">CY_SAR2_RESULT_ALIGNMENT_RIGHT</a>,</div><div class="line">    .signExtention = <a class="code" href="group__group__sar2__enums.html#ggab710a08c4f378212fccc7ef2388cd1fca39542cbc68a10be6ada97b4b7db52b30">CY_SAR2_SIGN_EXTENTION_UNSIGNED</a>,</div><div class="line">    .averageCount = 1U,</div><div class="line">    .rightShift = 0U,</div><div class="line">    .positiveReload = 0U,</div><div class="line">    .negativeReload = 0U,</div><div class="line">    .rangeDetectionMode = <a class="code" href="group__group__sar2__enums.html#gga835a6d564cab91f15a6cd1598b4fa792aee34dab51e8d0b5114ee6a09db965a5c">CY_SAR2_RANGE_DETECTION_MODE_INSIDE_RANGE</a>,</div><div class="line">    .rangeDetectionLoThreshold = 0U,</div><div class="line">    .rangeDetectionHiThreshold = 4095U,</div><div class="line">};</div></div><!-- fragment --><p> The ADC has an offset adjustment function to compensate for offset error.</p>
<p>It is possible to select code from +127 to -128 in a dec. for analog calibration. <br />
 The offset adjustment step is a quarter of 1LSb. <br />
 Offset = max( 0, min( 4095, floor( VIN/VREFH x 4096 + OFST/4 ) ) ) </p><div class="image">
<img src="sar2_offset_calibration.png" alt="sar2_offset_calibration.png"/>
</div>
 <dl class="section note"><dt>Note</dt><dd>Enable reference buffer mode using <a class="el" href="group__group__sar2__functions.html#gab2725bd7acf6658c561a1a4614c12c5d">Cy_SAR2_SetReferenceBufferMode</a> function.</dd></dl>
<p><br />
 Following code snippet can be used: </p><div class="fragment"><div class="line"><span class="comment">/* Scenario: SAR2 block 0 with it&#39;s clock source is configured, channel 2 is</span></div><div class="line"><span class="comment"> * not used. */</span></div><div class="line"><span class="comment">/* Calibration initial setting. */</span></div><div class="line"><a class="code" href="structcy__stc__sar2__analog__calibration__conifg__t.html">cy_stc_sar2_analog_calibration_conifg_t</a> calibrationConfig =</div><div class="line">{</div><div class="line">    .<a class="code" href="structcy__stc__sar2__analog__calibration__conifg__t.html#ad51f624937651cd514f4b863afc47692">offset</a> = 127ul,<span class="comment">/* Offset Calibration start setting */</span></div><div class="line">    .gain   = 15ul,<span class="comment">/* Gain Calibration start setting */</span></div><div class="line">};</div><div class="line"></div><div class="line"><span class="comment">/*******************************************************************************</span></div><div class="line"><span class="comment">* Function Name: getAdcValue</span></div><div class="line"><span class="comment">********************************************************************************</span></div><div class="line"><span class="comment">*</span></div><div class="line"><span class="comment">* Issues software trigger for the channel 2, waits for SAR2 block to complete</span></div><div class="line"><span class="comment">* it&#39;s calculation and returns calculated value.</span></div><div class="line"><span class="comment">*</span></div><div class="line"><span class="comment">* \return</span></div><div class="line"><span class="comment">* Measurement value</span></div><div class="line"><span class="comment">*</span></div><div class="line"><span class="comment">*******************************************************************************/</span></div><div class="line">uint16_t getAdcValue(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">    <span class="comment">/* Trigger ADC. */</span></div><div class="line">    <a class="code" href="group__group__sar2__functions.html#ga07a7023e4f6db655204d25a21b036651">Cy_SAR2_Channel_SoftwareTrigger</a>(PASS0_SAR0, 2U);</div><div class="line"></div><div class="line">    <span class="comment">/* Wait for group of single channel to complete. */</span></div><div class="line">    <span class="keywordflow">while</span> (<a class="code" href="group__group__sar2__macros__interrupt.html#gaa882e6a45272a4e28a148f6c496372c8">CY_SAR2_INT_GRP_DONE</a> != <a class="code" href="group__group__sar2__functions.html#gae07d8e288f6863cef7e8fa37fa2c0f55">Cy_SAR2_Channel_GetInterruptStatus</a>(PASS0_SAR0, 2U));</div><div class="line">    <a class="code" href="group__group__sar2__functions.html#ga3038fbd14b4fef98a91a8713c559472d">Cy_SAR2_Channel_ClearInterrupt</a>(PASS0_SAR0, 2U, <a class="code" href="group__group__sar2__macros__interrupt.html#gaa882e6a45272a4e28a148f6c496372c8">CY_SAR2_INT_GRP_DONE</a>);</div><div class="line"></div><div class="line">    <span class="comment">/* Get the result(s) */</span></div><div class="line">    <span class="keywordflow">return</span> (<a class="code" href="group__group__sar2__functions.html#ga6cf749ec06d3ab25ce139975f7baafcf">Cy_SAR2_Channel_GetResult</a>(PASS0_SAR0, 2U, NULL));</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">/*******************************************************************************</span></div><div class="line"><span class="comment">* Function Name: offset_Calibration</span></div><div class="line"><span class="comment">********************************************************************************</span></div><div class="line"><span class="comment">*</span></div><div class="line"><span class="comment">* Performs SAR block offset calibration</span></div><div class="line"><span class="comment">*</span></div><div class="line"><span class="comment">* \return</span></div><div class="line"><span class="comment">* Boolean value if calibration was successful.</span></div><div class="line"><span class="comment">*</span></div><div class="line"><span class="comment">*******************************************************************************/</span></div><div class="line"><span class="keywordtype">bool</span> offset_Calibration(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">    <span class="comment">/* Start ADC conversion and get the ADC value */</span></div><div class="line">    int16_t <a class="code" href="group__group__ipc__bt__data__structures.html#ga36692bbc61358ebc0e37a6fc6a395d28">result</a> = getAdcValue();</div><div class="line">    int16_t offset_VREFH = 0U;</div><div class="line">    int16_t offset_VREFL = 0U;</div><div class="line">    uint32_t value = 0U;</div><div class="line"></div><div class="line">    pass_0_saradc_0_sar_0_channel_2_config.<a class="code" href="structcy__stc__sar2__channel__config__t.html#a4f6314e95c3a7779d57518e3ed5192af">pinAddress</a> = <a class="code" href="group__group__sar2__enums.html#ggaff7c2edefeb5747dbe17f065a27973e3aec795970dff99c902d05a01b9ee043df">CY_SAR2_PIN_ADDRESS_VREF_L</a>;</div><div class="line">    <a class="code" href="group__group__sar2__functions.html#ga2a2919b5813338f4c40a74246cef135e">Cy_SAR2_SetAnalogCalibrationValue</a>(PASS0_SAR0, &amp;calibrationConfig);</div><div class="line"></div><div class="line">    <span class="comment">/* Initialize channel. */</span></div><div class="line">    <a class="code" href="group__group__sar2__functions.html#ga20289a8407d268ade39d00c18a7c14b8">Cy_SAR2_Channel_Init</a>(PASS0_SAR0, 2U, &amp;pass_0_saradc_0_sar_0_channel_2_config);</div><div class="line">    <span class="keywordflow">if</span>(result &gt; 0)</div><div class="line">    {</div><div class="line">        <span class="comment">/* Decrement the Value of Offset Compensation by &quot;1&quot; */</span></div><div class="line">        <span class="keywordflow">for</span>(offset_VREFL = 127; offset_VREFL &gt;= -128; offset_VREFL -= 1)</div><div class="line">        {</div><div class="line">            <span class="comment">/* Set &quot;offset_VREFL&quot; to offset register value */</span></div><div class="line">            calibrationConfig.<a class="code" href="structcy__stc__sar2__analog__calibration__conifg__t.html#ad51f624937651cd514f4b863afc47692">offset</a> = offset_VREFL;</div><div class="line">            <a class="code" href="group__group__sar2__functions.html#ga2a2919b5813338f4c40a74246cef135e">Cy_SAR2_SetAnalogCalibrationValue</a>(PASS0_SAR0, &amp;calibrationConfig);</div><div class="line"></div><div class="line">            <span class="comment">/* Get ADC conversion value. */</span></div><div class="line">            result = getAdcValue();</div><div class="line"></div><div class="line">            <span class="comment">/* Does the ADC conversion value equal to 0? */</span></div><div class="line">            <span class="keywordflow">if</span>(result == 0)</div><div class="line">            {</div><div class="line">                <span class="keywordflow">break</span>;</div><div class="line">            }</div><div class="line"></div><div class="line">            <span class="comment">/* If offset has reached lower bound. */</span></div><div class="line">            <span class="keywordflow">if</span>(offset_VREFL == -128)</div><div class="line">            {</div><div class="line">                <span class="comment">/* Report error. */</span></div><div class="line">                <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line">            }</div><div class="line">        }</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">    {</div><div class="line">        <span class="comment">/* End of Offset Adjustment with Abnormality. */</span></div><div class="line">        <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="comment">/* Set VREFH Voltage to Input */</span></div><div class="line">    pass_0_saradc_0_sar_0_channel_2_config.<a class="code" href="structcy__stc__sar2__channel__config__t.html#a4f6314e95c3a7779d57518e3ed5192af">pinAddress</a> = <a class="code" href="group__group__sar2__enums.html#ggaff7c2edefeb5747dbe17f065a27973e3a57ebc372e9b9b6d42a8523339029cf20">CY_SAR2_PIN_ADDRESS_VREF_H</a>;</div><div class="line"></div><div class="line">    <span class="comment">/* Set Offset Compensation to &quot;-128&quot; and init channel. */</span></div><div class="line">    calibrationConfig.<a class="code" href="structcy__stc__sar2__analog__calibration__conifg__t.html#ad51f624937651cd514f4b863afc47692">offset</a> = -128;</div><div class="line">    <a class="code" href="group__group__sar2__functions.html#ga2a2919b5813338f4c40a74246cef135e">Cy_SAR2_SetAnalogCalibrationValue</a>(PASS0_SAR0, &amp;calibrationConfig);</div><div class="line">    <a class="code" href="group__group__sar2__functions.html#ga20289a8407d268ade39d00c18a7c14b8">Cy_SAR2_Channel_Init</a>(PASS0_SAR0, 2u, &amp;pass_0_saradc_0_sar_0_channel_2_config);</div><div class="line"></div><div class="line">    <span class="comment">/* Start ADC Conversion and get the A/D value. */</span></div><div class="line">    result = getAdcValue();</div><div class="line"></div><div class="line">    <span class="comment">/* Is the ADC Conversion value lower than 0xFFF */</span></div><div class="line">    <span class="keywordflow">if</span>(result &lt; 0xFFF)</div><div class="line">    {</div><div class="line">        <span class="comment">/* Increment the Value of Offset Compensation by &quot;1&quot;. */</span></div><div class="line">        <span class="keywordflow">for</span>(offset_VREFH = -128; offset_VREFH &lt;= 127; offset_VREFH += 1)</div><div class="line">        {</div><div class="line">            <span class="comment">/* Set &quot;offset_VREFH&quot; to offset register value. */</span></div><div class="line">            calibrationConfig.<a class="code" href="structcy__stc__sar2__analog__calibration__conifg__t.html#ad51f624937651cd514f4b863afc47692">offset</a> = offset_VREFH;</div><div class="line">            <a class="code" href="group__group__sar2__functions.html#ga2a2919b5813338f4c40a74246cef135e">Cy_SAR2_SetAnalogCalibrationValue</a>(PASS0_SAR0, &amp;calibrationConfig);</div><div class="line"></div><div class="line">            <span class="comment">/* Get ADC Conversion value. */</span></div><div class="line">            result = getAdcValue();</div><div class="line"></div><div class="line">            <span class="comment">/* Does the ADC Conversion value Equal to &quot;4095&quot;? */</span></div><div class="line">            <span class="keywordflow">if</span>(result == 0xFFF)</div><div class="line">            {</div><div class="line">                <span class="keywordflow">break</span>;</div><div class="line">            }</div><div class="line"></div><div class="line">            <span class="comment">/* Does the value of offset compensation equal to &quot;127&quot;? */</span></div><div class="line">            <span class="keywordflow">if</span>(offset_VREFH == 127)</div><div class="line">            {</div><div class="line">                <span class="comment">/* Offset adjustment failed - report error. */</span></div><div class="line">                <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line">            }</div><div class="line">        }</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">    {</div><div class="line">        <span class="comment">/* Offset adjustment failed - report error. */</span></div><div class="line">        <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="comment">/* Does &quot;(floor((offset_VREFH+offset_VREFL)/2) + 2)&quot; greater than &quot;125&quot; ?*/</span></div><div class="line">    value = (floor((offset_VREFH+offset_VREFL)/2U) + 2U);</div><div class="line">    <span class="keywordflow">if</span>(value &gt; 125U)</div><div class="line">    {</div><div class="line">        <span class="comment">/* Offset adjustment failed - report error. */</span></div><div class="line">        <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="comment">/* Set the value of offset compensation to (floor((offset_VREFH+offset_VREFL)/2) + 2) */</span></div><div class="line">    calibrationConfig.<a class="code" href="structcy__stc__sar2__analog__calibration__conifg__t.html#ad51f624937651cd514f4b863afc47692">offset</a> = (floor((offset_VREFH+offset_VREFL)/2U) + 2U);</div><div class="line">    </div><div class="line">    <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line">}</div></div><!-- fragment --><p> After that, the Gain should also be calibrated as well. The ADC has a gain adjustment function to compensate for gain error. It is possible to set code from +15 to -15 dec. The gain adjustment step is a quarter of 1LSb. <br />
 Gain = max(0, min(4095, floor((4096 - GAIN)/VREFH x (VIN - VREFH/2) + 2048))) </p><div class="image">
<img src="sar2_gain_calibration.png" alt="sar2_gain_calibration.png"/>
</div>
 <div class="fragment"><div class="line"><span class="comment">/* Scenario: SAR2 block 0 is left after offset calibration intact, global</span></div><div class="line"><span class="comment"> * structure is still available with offset calibration results. */</span></div><div class="line"><span class="comment">/*******************************************************************************</span></div><div class="line"><span class="comment">* Function Name: gain_Calibration</span></div><div class="line"><span class="comment">********************************************************************************</span></div><div class="line"><span class="comment">*</span></div><div class="line"><span class="comment">* Performs SAR block gain calibration</span></div><div class="line"><span class="comment">*</span></div><div class="line"><span class="comment">* \return</span></div><div class="line"><span class="comment">* Boolean value if calibration was successful.</span></div><div class="line"><span class="comment">*</span></div><div class="line"><span class="comment">*******************************************************************************/</span></div><div class="line"><span class="keywordtype">bool</span> gain_Calibration(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">    int16_t gain;</div><div class="line">    int16_t result = 0U;</div><div class="line">    <span class="comment">/* Set Gain Correction setting to &quot;15&quot;. */</span></div><div class="line">    calibrationConfig.<a class="code" href="structcy__stc__sar2__analog__calibration__conifg__t.html#adf4c378248322200e3f122444d1af760">gain</a> = 15;</div><div class="line"></div><div class="line">    <span class="comment">/* Set VREFL Voltage to Input and init the channel. */</span></div><div class="line">    pass_0_saradc_0_sar_0_channel_2_config.<a class="code" href="structcy__stc__sar2__channel__config__t.html#a4f6314e95c3a7779d57518e3ed5192af">pinAddress</a> = <a class="code" href="group__group__sar2__enums.html#ggaff7c2edefeb5747dbe17f065a27973e3aec795970dff99c902d05a01b9ee043df">CY_SAR2_PIN_ADDRESS_VREF_L</a>;</div><div class="line">    <a class="code" href="group__group__sar2__functions.html#ga20289a8407d268ade39d00c18a7c14b8">Cy_SAR2_Channel_Init</a>(PASS0_SAR0, 2u, &amp;pass_0_saradc_0_sar_0_channel_2_config);</div><div class="line"></div><div class="line">    <span class="comment">/* Apply the initial calibration settings. */</span></div><div class="line">    <a class="code" href="group__group__sar2__functions.html#ga2a2919b5813338f4c40a74246cef135e">Cy_SAR2_SetAnalogCalibrationValue</a>(PASS0_SAR0, &amp;calibrationConfig);</div><div class="line"></div><div class="line">    <span class="comment">/* Start ADC value Conversion */</span></div><div class="line">    result = getAdcValue();</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span>(result &gt; 0)</div><div class="line">    {</div><div class="line">         <span class="keywordflow">for</span>(gain = 15; gain &gt;=-14; gain -= 1)</div><div class="line">         {</div><div class="line">            <span class="comment">/* Set gain to register */</span></div><div class="line">            calibrationConfig.<a class="code" href="structcy__stc__sar2__analog__calibration__conifg__t.html#adf4c378248322200e3f122444d1af760">gain</a> = gain;</div><div class="line">            <a class="code" href="group__group__sar2__functions.html#ga2a2919b5813338f4c40a74246cef135e">Cy_SAR2_SetAnalogCalibrationValue</a>(PASS0_SAR0, &amp;calibrationConfig);</div><div class="line"></div><div class="line">            result = getAdcValue();</div><div class="line"></div><div class="line">            <span class="keywordflow">if</span>(result == 0)</div><div class="line">            {</div><div class="line">                <span class="comment">/* Set gain compensation to &quot;gain - 1&quot; */</span></div><div class="line">                calibrationConfig.<a class="code" href="structcy__stc__sar2__analog__calibration__conifg__t.html#adf4c378248322200e3f122444d1af760">gain</a> = gain - 1;</div><div class="line">                <a class="code" href="group__group__sar2__functions.html#ga2a2919b5813338f4c40a74246cef135e">Cy_SAR2_SetAnalogCalibrationValue</a>(PASS0_SAR0, &amp;calibrationConfig);</div><div class="line"></div><div class="line">                <span class="keywordflow">break</span>;</div><div class="line">            }</div><div class="line"></div><div class="line">            <span class="keywordflow">if</span>(gain == -14)</div><div class="line">            {</div><div class="line">                <span class="comment">/* Gain adjustment failed - report error. */</span></div><div class="line">                <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line">            }</div><div class="line">         }</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line">}</div></div><!-- fragment --><p> <br />
 Once done, the calibrationConfig global structure contains calibration data for SAR2 block 0. Calibration is advised to be done as frequent as possible. </p>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part
<div id="nav-path" class="navpath">
    <ul>
        <li class="footer">
            Generated for <b>MTB CAT1 Peripheral driver library</b> by <b>Cypress Semiconductor Corporation</b>.
            All rights reserved.
        </li>
    </ul>
</div>
-->
</body>
</html>
